package swagger.model;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import common.util.BeanUtil;
import common.util.ToolUtil;

public class EvaluateSwaggerModel extends SwaggerModelObject {

	private Integer evaluateId;
	
	private String evaluateUser;
	
	private Timestamp evaluateTime;
	
	private Integer evaluateCount;

	private String evaluateContext;
	
	private Integer evaluate;
	
	private Float sorce;
	
	protected Object getId() {
		return evaluateId;
	}
	
	public Integer getEvaluateSorce(int evaluate){
		return evaluate == this.evaluate.intValue() ? sorce.intValue() : 0;
	}
	
	public static Integer getEvaluateBySorce(int sorce){
		return sorce == 3 ? 2 : sorce < 3 ? 3 : 1;
	}
	
	public Integer getGood(){
		return getEvaluateSorce(1);
	}
	
	public Integer getMidle(){
		return getEvaluateSorce(2);
	}
	
	public Integer getBad(){
		return getEvaluateSorce(3);
	}

	public static List<EvaluateSwaggerModel> fromList(List<Map<String, Object>> list){
		List<EvaluateSwaggerModel> evaluates = new ArrayList<EvaluateSwaggerModel>();
		for (Map<String, Object> item : list){
			EvaluateSwaggerModel evaluate = BeanUtil.fromMap(item, EvaluateSwaggerModel.class);
				if (! evaluates.contains(evaluate)){
					evaluates.add(evaluate);
				}
		}
		return evaluates;
	}
	
	public String getEvaluateUser() {
		return evaluateUser;
	}

	public void setEvaluateUser(String evaluateUser) {
		this.evaluateUser = evaluateUser;
	}

	public String getEvaluateTime() {
		return ToolUtil.serializDate("yyyy-MM-dd HH:mm:ss", evaluateTime).toString();
		//return evaluateTime;
	}

	public void setEvaluateTime(Timestamp evaluateTime) {
		this.evaluateTime = evaluateTime;
	}

	public Integer getEvaluateCount() {
		return evaluateCount;
	}

	public void setEvaluateCount(Integer evaluateCount) {
		this.evaluateCount = evaluateCount;
	}

	public String getEvaluateContext() {
		return evaluateContext;
	}

	public void setEvaluateContext(String evaluateContext) {
		this.evaluateContext = evaluateContext;
	}

	public Float getSorce() {
		return sorce;
	}

	public void setSorce(Float sorce) {
		this.sorce = sorce;
	}

	public Integer getEvaluateId() {
		return evaluateId;
	}

	public void setEvaluateId(Integer evaluateId) {
		this.evaluateId = evaluateId;
	}

	public Integer getEvaluate() {
		return evaluate;
	}

	public void setEvaluate(Integer evaluate) {
		this.evaluate = evaluate;
	}
	
}
